const API = require('../../pages/api/index')
const {
  typeJson
} = require('../../utils/typejson')
let prolist = wx.getStorageSync('prolist') == '' ? wx.getStorageSync('prolist') : JSON.parse(wx.getStorageSync('prolist'))







Page({

  /**
   * 页面的初始数据
   */
  data: {
    title:"",
    pulldown: "",
    pullup: 2,
    addButton: true,
    Refresh: false,
    prolist: wx.getStorageSync('prolist') == '' ? wx.getStorageSync('prolist') : JSON.parse(wx.getStorageSync('prolist')),
    option:[
      { text: '查自己', value: 1 },
      { text: '查待自己审核', value: 2 },
    ],
    bgc:"background:skyblue",
    bga:"",
    type:1,
    listConfig: [
      {
        label: '流程名称',
        prop: 'processName',

      },
      // {
      //   label: '申请时间',
      //   prop: 'createDate'
      // },
      {
        label: '审批状态',
        prop: 'status',
        jsonType: typeJson.typeStatus,
      },

    
    ],

    slide: {
      slideButton: {
        text: '编辑',
        extClass: 'test',
        src: '/page/weui/cell/icon_star.svg', // icon的路径
      },
      formConfig: [{
          label: '带班队长',
          prop: 'safeappName',
        },
        {
          label: "任务概要",
          prop: "taskProfiles",
          type: "textarea"
        },
        {
          label: "带班日期",
          prop: "meetingDate",
          type: "dateTime",
          required: true,
        },

        {
          label: '参会部门及人员',
          prop: 'attendMinerIds',
          hidden: "look",
          required: true,
          type: "tree",
          net: {
            url: '/app/siteMeeting/getUserTree',
            method: 'post',
            data: {
              mineId: true,
            },
          },
          prat: 'attendDepart',

        },
        {
          label: "参会部门及人员",
          prop: "options",
          hidden: "edit",
          disdata: "line",

        },

        {
          label: "工作安排",
          prop: "missionSchedule",
          type: "textarea"
        },
        {
          label: "详细记录",
          prop: "remarks",
          type: "textarea",
          required: true,
        },
        {
          label: "交接班情况",
          prop: "isClean",
          jsonType: typeJson.isClean,
          type: 'dropDown',
          required: true,
        },
        {
          label: "安全作业事项",
          prop: "safeWork",
          type: "textarea"
        },

        // {
        //   label: "审批状态",
        //   prop: 'approveStatus',
        //   jsonType: typeJson.approveStatus,
        //   type: 'dropDown',
        //   required:true,
        // },
        // {
        //   label: "审批人",
        //   prop: "approverId",
        //   required:true,
        //   type: 'dropDownSearch',
        //   hidden: 'look',
        //   tag: 'userid',
        //   net: {
        //     url: '/app/memberinfo/getList',
        //     method: 'post',
        //     key: 'nickName',
        //     data:{
        //       mineId: true,
        //     },
        //     value: 'memberId'
        //   }
        // },
        // {
        //   label: '审批人',
        //   prop: 'approverName',
        //   hidden: 'edit',
        // },
        {
          label: '上传照片',
          prop: 'file',
          type: 'image',

        },

      ],
    },

    formConfig: [

      {
        label: "审批表名称",
        prop: "processName",  
        required: true,
      },
      {
        label: '停机开始时间',
        prop: 'appalyStartTime',
        type:"dateTime",
        required:true,
      },
      {
        label: '停机结束时间',
        prop: 'appalyEndTime',
        type:"dateTime",
        required:true,
      },



      {
        label: "停机单位",
        prop: "dept",
        required:true,
        type: "textarea"
      },
      {
        label: "负责人",
        prop: "headUser",
    
        required: true,
      },
     
      {
        label: '停机事由',
        prop:"matter",
        required:true,
        type: "textarea"
      },
      {
        label: "停机主要工作内容",
        prop: "content",
        required:true,
        type: "textarea"
      },

      {
        label: "停机期间采取主要安全措施",
        prop:"measure",
        required:true,
        type: "textarea"
      },
      {
        label: "停机期间对井下通风所采取的安全措施",
        prop: "windMeasure",
        type: "textarea",
        required: true,
      },
      

    ],


    net: {
      select:{
  
      },
      
      delete: {
        url: '/app/siteMeeting/delete',
        method: 'post',
        data: {

        }
      },
      insert: {
        url: '/app/approvalRecord/insert',
        method: 'post',
        data: {
          mineId: true,
          // teamLeaderId: "userid",
        },
        type:'下一步'
      },
      update: {
        url: '/app/approvalRecord/update',
        method: 'post',
        data: {

        }
      }
    },
    showCom: true
  },

  styleColor(e){
 
  let {type} = e.currentTarget.dataset;
  if(type=='2'){
  
    this.getlist(type)
    this.setData({
      bgc:"background:skyblue;",  
      bga:""
    })
    this.onShow()
  }else{
    this.getlist(type)
    this.setData({
      bga:"background:skyblue;",
      bgc:""
    })
    this.onShow()
  }
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad:function(e){
    
   this.getlist(2)

  },

  getlist(T){
    let {userid} = this.data.prolist;
   
    this.setData({
      net:{
        select: {
          url: `/app/approvalRecord/getById/${userid}/${Number(T)}`,
          method: 'get',
          data: {
            mineId: true,  
          }
        },
        delete: {
          url: '/app/siteMeeting/delete',
          method: 'post',
          data: {
  
          }
        },
        insert: {
          url: '/app/approvalRecord/insert',
          method: 'post',
          data: {
            mineId: true,
            // teamLeaderId: "userid",
          },
          type:'下一步',
          code:2
        }, 
        update: {
          url: '/app/approvalRecord/update',
          method: 'post',
          data: {
  
          }
        }
      }
    })

  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {


    this.setData({
      showCom: false
    })

    this.setData({
      showCom: true
    })
  },



  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    wx.showLoading({
      title: '刷新中...',
    })
    this.setData({
      Refresh: true
    })
    wx.hideLoading();
    wx.stopPullDownRefresh()
    this.setData({
      Refresh: false
    })
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () { 
    this.setData({
      pullup: this.data.pullup + 1
    })
  },


  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})